package com.ys.nms.module.business.dal.mysql.router;

import java.util.*;

import com.ys.nms.framework.common.pojo.PageResult;
import com.ys.nms.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ys.nms.framework.mybatis.core.mapper.BaseMapperX;
import com.ys.nms.module.business.dal.dataobject.router.RouteDO;
import org.apache.ibatis.annotations.Mapper;
import com.ys.nms.module.business.controller.admin.router.vo.*;

/**
 * 路由 Mapper
 *
 * @author zzy
 */
@Mapper
public interface RouteMapper extends BaseMapperX<RouteDO> {

    default PageResult<RouteDO> selectPage(RoutePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RouteDO>()
                .eqIfPresent(RouteDO::getDeviceId, reqVO.getDeviceId())
                .eqIfPresent(RouteDO::getPortId, reqVO.getPortId())
                .likeIfPresent(RouteDO::getContextName, reqVO.getContextName())
                .eqIfPresent(RouteDO::getInetCidrRouteIfIndex, reqVO.getInetCidrRouteIfIndex())
                .eqIfPresent(RouteDO::getInetCidrRouteType, reqVO.getInetCidrRouteType())
                .eqIfPresent(RouteDO::getInetCidrRouteNextHop, reqVO.getInetCidrRouteNextHop())
                .orderByDesc(RouteDO::getPortId));
    }

}